package view;

import java.awt.Color;
import java.awt.Component;
import java.util.Iterator;

import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.JPanel;

import model.item.Inventory;
import model.item.InventoryItem;

public class MerchantPanel extends JPanel {

	private Inventory inventory;
	private JLabel header;
	private JButton buyButton;
	
	public MerchantPanel(Inventory inventory) {
		this.inventory = inventory;
		setLayout(null);
		setLocation(300,0);
		setVisible(true);
		
		setSize(300,370);
		setBackground(Color.BLACK);
		
		header = new JLabel("Merchant's Inventory");
		header.setSize(300,50);
		header.setLocation(0,0);
		add(header);
		
		Iterator<InventoryItem> iter = inventory.getInventory();
		
		int currY = 50;
		
		while ( iter.hasNext() ) {
			InventoryItem item = iter.next();
			ImageIcon itemPic = new ImageIcon(item.getGraphicID());
			JLabel picLabel = new JLabel(itemPic);
			String description = item.getName();
			JLabel stringLabel = new JLabel(description);
			int price = item.getValue();
			price *= 2;
			JLabel priceLabel = new JLabel("" + price);
			picLabel.setSize(50,32);
			stringLabel.setSize(200,32);
			priceLabel.setSize(50,32);
			picLabel.setLocation(0,currY);
			stringLabel.setLocation(50,currY);
			priceLabel.setLocation(250,currY);
			currY += 32;		
		}
		
		buyButton = new JButton("Buy");
		buyButton.setSize(150,30);
		buyButton.setLocation(75,380);
		buyButton.setBackground(Color.BLACK);
		buyButton.setForeground(Color.RED);
		add(buyButton);
	}
	
	public static void main( String[] args ) {
		
	}
}
